TOOL.Category = "NPC Control"
TOOL.Name = "NPC Health Modifier"
TOOL.Command = nil
TOOL.ConfigName = ""

if CLIENT then
  language.Add( "Tool_npc_health_modifier_name", "NPC Health Modifiers" )
  language.Add( "Tool_npc_health_modifier_desc", "Change an NPCs health with the push of a button" )
  language.Add( "Tool_npc_health_modifier_0", "Left-Click to change an NPCs health (In percentage)" )
end

TOOL.ClientConVar[ "newhealth" ] = "100"

function TOOL:LeftClick( trace )
  if (trace.Entity:IsValid() && trace.Entity:IsNPC()) then
    if SERVER then
      local newhp = self:GetClientNumber("newhealth", 100)/100
      newhp = trace.Entity:GetMaxHealth()*newhp
      self:GetOwner():PrintMessage( HUD_PRINTTALK, "That NPC now has " .. tostring(newhp) .. "/" .. trace.Entity:GetMaxHealth() .. " of his health" )
      trace.Entity:SetHealth(newhp)
    end
  end
  return true
end

function TOOL.BuildCPanel(panel)
  panel:AddControl("Header", { Text = "NPC Health Modifier" })
  panel:AddControl("Slider", { Label = "Health Percentage", Command = "npc_health_modifier_newhealth", min = 1, max = 100 })
end
